package com.glenet.salary.dao;

import java.util.ArrayList;
import java.util.List;

import org.apache.ibatis.session.SqlSession;

import com.glenet.salary.entities.HrTemplate;
import com.glenet.salary.util.SessionFactoryUtil;

public class HrTemplateDao extends HrDaoSuport {
	@SuppressWarnings("unchecked")
	public List<HrTemplate> getTemplates(){
		List<HrTemplate> maps = new ArrayList<HrTemplate>();
		try {
			SqlSession session = SessionFactoryUtil.openSession();
			maps = (List<HrTemplate>) session.selectList("HrTemplate.getTemplates");
			session.commit();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return maps;
	}
	
	public HrTemplate getTemplate(Long id){
		HrTemplate template = null;
		try {
			SqlSession session = SessionFactoryUtil.openSession();
			template = (HrTemplate) session.selectOne("HrTemplate.getTemplate", id);
			session.commit();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return template;
	}
}
